<?php
include_once '../AtacCommunicator/ACBusWaitingTimes.php';
include_once '../Exceptions/CommunicationException.php';
include_once '../InfoManager/InfoManager.php';
include_once '../Model/BusStop.php';
include_once '../Model/Location.php';
include_once '../Model/Address.php';
include_once '../Model/GPS.php';
include_once '../Utility/DebugLogs.php';


if(isset($_GET['stopID']) && isset($_GET['lineNum'])){
	try{
		$stop = new BusStop(null,RMobUtils::escape_var($_GET['stopID']));
		$atacHandler = new ACBusWaitingTimes();
		//Prendo gli autobus in arrivo alla fermata
		$buses = $atacHandler->getIncomingBusesAtStop($stop);
		foreach($buses as $bus){
			//Se l'autobus è in arrivo, lo posso prendere
			if($bus->getLine() == $_GET['lineNum'] && $bus->getTimeLeft() == 0 && $bus->getStopsLeft() == 0){
				echo "Hai preso l'autobus ".$_GET['lineNum'];
			}
		}
	}catch(Exception $e){
		$e->toXML(EXTENDED_MODE);
	}
}


?>
